/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.diagram.classdiagram.figures;

import org.eclipse.draw2d.PositionConstants;

import com.cea.papyrus.core.PapyrusPlugin;
import com.cea.papyrus.core.figures.LabelFigure;


/**
 * This is the class to represent a reception of signal.
 */
public class ReceptionFigure extends LabelFigure{
	
	/**
	 * The name of the reception.
	 */
	private String name;
	
	/**
	 * The Constant RECEPTION_PREFIX.
	 */
	private final static String RECEPTION_PREFIX="signal";
	
	/**
	 * The stereotype string.
	 */
	private String stereotype=RECEPTION_PREFIX;

	/**
	 * The constructor. This is a extended label where text is placed at left.
	 */
	public ReceptionFigure(){
		this.setTextAlignment(PositionConstants.LEFT);
		this.setLabelAlignment(PositionConstants.LEFT);
	}

	/**
	 * Sets the name.
	 * 
	 * @param name the name
	 */
	public void setName(String name){
		this.name=name;	
		this.display();
	}
	
	/**
	 * Display the text in the label.
	 */
	private void display(){
		this.setText(stereotype+ " "+name);
		this.setTextAlignment(PositionConstants.LEFT);
		this.setLabelAlignment(PositionConstants.LEFT);
	}

	/**
	 * Gets the name.
	 * 
	 * @return the name
	 */
	public String getName(){
		return name;}

	/**
	 * Refresh stereotypes.
	 * 
	 * @param presentation the presentation
	 * @param hasIcon the has icon
	 * @param hasShape the has shape
	 * @param stereotypes the stereotypes
	 */
	public void refreshStereotypes(String stereotypes, String presentation, boolean hasIcon, boolean hasShape) {

		if (stereotypes.equals("")) {
			this.setStereotypes(null);
			return;
		}

		this.setStereotypes(stereotypes);//add stereotypes on the class figure		
		return;
	}

	/**
	 * Sets the stereotypes.
	 * 
	 * @param stereotypes the stereotypes
	 */
	public void setStereotypes(String stereotypes) {		
		if( stereotypes == null ) { 
			this.stereotype=PapyrusPlugin.ST_LEFT+RECEPTION_PREFIX+PapyrusPlugin.ST_RIGHT;	
			this.display();
			return;
		}

		// Set stereotype text on figure
		if (!stereotypes.equals("")) {
			this.stereotype=PapyrusPlugin.ST_LEFT+stereotypes+PapyrusPlugin.ST_RIGHT;	
		} else {
			this.stereotype="";
		}
		this.display();
	}



}
